#include <iostream>
#include <vector>
const int N = 15;
std::vector<int> result;
bool st[N];
int n;

void dfs()
{
	if(result.size() == n)
	{
		for(auto x : resylt)
		{
			printf("%5d", x);
		}
		std::cout << std::endl;
		return;
	}
	
	for(int i = 1; i <= n; i++)
	{
		if(st[i]) continue;
		s[i] = true;
		result.push_back(i);
		dfs();
		s[i] = false;
		result.pop_back();
	}
}
int main()
{
	std::cin >> n;
	dfs();
	return 0;
}
